<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Returns the sub-elements of the current element</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="simplexmliterator.current.html">SimpleXMLIterator::current</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="simplexmliterator.haschildren.html">SimpleXMLIterator::hasChildren</a></div>
 <div class="up"><a href="class.simplexmliterator.html">SimpleXMLIterator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="simplexmliterator.getchildren" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">SimpleXMLIterator::getChildren</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.1.0)</p><p class="refpurpose"><span class="refname">SimpleXMLIterator::getChildren</span> &mdash; <span class="dc-title">Returns the sub-elements of the current element</span></p>

 </div>
 <div class="refsect1 description" id="refsect1-simplexmliterator.getchildren-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type"><a href="class.simplexmliterator.html" class="type SimpleXMLIterator">SimpleXMLIterator</a></span> <span class="methodname"><strong>SimpleXMLIterator::getChildren</strong></span>
    ( <span class="methodparam">void</span>
   )</div>

  <p class="para rdfs-comment">
   This method returns a <a href="class.simplexmliterator.html" class="classname">SimpleXMLIterator</a> object
   containing sub-elements of the current <a href="class.simplexmliterator.html" class="classname">SimpleXMLIterator</a>
   element.
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-simplexmliterator.getchildren-parameters">
  <h3 class="title">参数</h3>
  <p class="para">此函数没有参数。</p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-simplexmliterator.getchildren-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns a <a href="class.simplexmliterator.html" class="classname">SimpleXMLIterator</a> object containing
   the sub-elements of the current element.
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-simplexmliterator.getchildren-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-5395">
    <p><strong>Example #1 Return the sub-elements of the current element</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br />$xml&nbsp;</span><span style="color: #007700">=&nbsp;&lt;&lt;&lt;XML<br /></span><span style="color: #DD0000">&lt;books&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;book&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;title&gt;PHP&nbsp;Basics&lt;/title&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&lt;author&gt;Jim&nbsp;Smith&lt;/author&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;/book&gt;<br />&nbsp;&nbsp;&nbsp;&nbsp;&lt;book&gt;XML&nbsp;basics&lt;/book&gt;<br />&lt;/books&gt;<br /></span><span style="color: #007700">XML;<br /><br /></span><span style="color: #0000BB">$xmlIterator&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">SimpleXMLIterator</span><span style="color: #007700">(</span><span style="color: #0000BB">$xml</span><span style="color: #007700">);<br />for(&nbsp;</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">rewind</span><span style="color: #007700">();&nbsp;</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">valid</span><span style="color: #007700">();&nbsp;</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">next</span><span style="color: #007700">()&nbsp;)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;foreach(</span><span style="color: #0000BB">$xmlIterator</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">getChildren</span><span style="color: #007700">()&nbsp;as&nbsp;</span><span style="color: #0000BB">$name&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">$data</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;echo&nbsp;</span><span style="color: #DD0000">"The&nbsp;</span><span style="color: #0000BB">$name</span><span style="color: #DD0000">&nbsp;is&nbsp;'</span><span style="color: #0000BB">$data</span><span style="color: #DD0000">'&nbsp;from&nbsp;the&nbsp;class&nbsp;"&nbsp;</span><span style="color: #007700">.&nbsp;</span><span style="color: #0000BB">get_class</span><span style="color: #007700">(</span><span style="color: #0000BB">$data</span><span style="color: #007700">)&nbsp;.&nbsp;</span><span style="color: #DD0000">"\n"</span><span style="color: #007700">;<br />&nbsp;&nbsp;&nbsp;&nbsp;}<br />}<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
The title is &#039;PHP Basics&#039; from the class SimpleXMLIterator
The author is &#039;Jim Smith&#039; from the class SimpleXMLIterator
</pre></div>
    </div>
   </div>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="simplexmliterator.current.html">SimpleXMLIterator::current</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="simplexmliterator.haschildren.html">SimpleXMLIterator::hasChildren</a></div>
 <div class="up"><a href="class.simplexmliterator.html">SimpleXMLIterator</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
